package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.SysDepartmentControllerApi;
import com.nineclock.system.service.SysDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
@RequestMapping("/department")
public class SysDepartmentController implements SysDepartmentControllerApi {
    @Autowired
    SysDepartmentService sysDepartmentService;


    /**
     * 根据员工id查询考勤组，如果没有员工id，则查找部门id--》父级部门id--》
     * @param companyUserId
     * @return
     */
    @Override
    @GetMapping("/allDepId/{companyUserId}")
    public Result<List<Long>> queryDepartmentsByUserId(@PathVariable Long companyUserId) {
        List<Long> ids =  sysDepartmentService.queryDepartmentsByUserId(companyUserId);
        return Result.success(ids);
    }
}
